/*
 * AerogelSD.hh
 *
 *  Created on: 15.02.2011
 *      Author: ed
 */

#ifndef AEROGELSD_HH_
#define AEROGELSD_HH_
#include "G4VSensitiveDetector.hh"
#include "globals.hh"
#include "TrackerMessenger.hh"
#include "MyEvent.hh"
#include "TTree.h"
#include "TFile.h"
class TFile;
class G4HCofThisEvent;
class TrackerMessenger;
class MyEvent;

typedef struct
{
	G4double detectorRadius;
	G4int nCollisions;
	G4int lightOutput;
	G4double lightCollection;
	G4int particlesPerEvent;
	G4double aerogelSc,aerogelAbsorptionIndex;

}Event;

class TrackerSD : public G4VSensitiveDetector
{
public:
	TrackerSD(G4String name);
	virtual ~TrackerSD();
	void Initialize(G4HCofThisEvent*HCE);
	void EndOfEvent(G4HCofThisEvent*HCE);
	G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
	inline void setDetectorRadius(G4double radius){detectorRadius=radius;}
	void DrawHist();
private:
	TFile *f;
	G4double detectorRadius;
	G4int nCollisions;
	G4int lightOutput;
	G4int nEvents;
	MyEvent* evt;
	TTree* tree;
	Event event;
	TrackerMessenger *trackerMessenger;
	G4double aerogelRefractiveIndex,aerogelAbsorptionIndex;
	void PrintEvent()
	{
		G4cout<<"Detector Radius:"<<event.detectorRadius<<"\n"
				<<"Number of Collisions:"<<event.nCollisions<<G4endl
				<<"Light Output:"<<event.lightOutput<<G4endl
				<<"particlesPerEvent:"<<event.particlesPerEvent<<G4endl
				<<"aerogelLSc:"<<event.aerogelSc<<G4endl
				<<"aerogelLAbs:"<<event.aerogelAbsorptionIndex<<G4endl;
	}

};

#endif /* AEROGELSD_HH_ */
